package com.kaishengit.web;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.util.HttpUtil;

public class GoogleServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String city = request.getParameter("city");
		
		String xml = HttpUtil.getHttpContent("http://www.google.com/ig/api?hl=zh-cn&ie=u7-8&weather="+city, "GBK");
		response.setContentType("text/xml;charset=UTF-8");
		PrintWriter out = response.getWriter();
		out.print(xml);
		out.flush();
		out.close();
	}
}
